/**
 * @description: 钉钉告警日志删除  每天10点删除前一周的日志
 * @version: 0.0.1
 * @author: z..
 * @Date: 2023-06-12 18:16:39
 */

import { Config } from '@midwayjs/decorator';
import { Provide, Inject } from '@midwayjs/core';

import { RobotAlarmLogsModel } from "../entity/robot_alarm_logs.method";
import { RobotWebapiLogsModel } from "../entity/robot_webapi_logs.method"

import { Context } from '@midwayjs/koa';

@Provide()
export class DingtalkRobotLogsService {

  @Config('appConfig')
  appConfig: any;

  @Inject()
  ctx: Context;

  @Inject()
  RobotWebapiLogsModel: RobotWebapiLogsModel;

  @Inject()
  RobotAlarmLogsModel: RobotAlarmLogsModel;

  /**
   * 删除一周前的日志
   * @returns 
   */
  async delWeekagoLogs(): Promise<any> {
    //  删除告警日志
    await this.RobotAlarmLogsModel.delWeekagoLogs();
    // 删除监控日志
    await this.RobotWebapiLogsModel.delWeekagoLogs();
    return true;
  }

}